package com.fd.generator;

import org.mybatis.generator.api.IntrospectedColumn;
import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.dom.java.Field;
import org.mybatis.generator.api.dom.java.Method;
import org.mybatis.generator.internal.DefaultCommentGenerator;

/**
 * mybatis generator 代码注释
 * Created by arkor on 2016-03-25.
 */
public class ZchCommentGenerator extends DefaultCommentGenerator {
    @Override
    public void addGetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
        if (introspectedColumn.getRemarks() != null && !introspectedColumn.getRemarks().equals("")) {
            method.addJavaDocLine("/**");
            method.addJavaDocLine(" * "+introspectedColumn.getRemarks());
            method.addJavaDocLine(" * @return  "+introspectedColumn.getActualColumnName()+"  "+introspectedColumn.getRemarks());
            this.addJavadocTag(method, false);
            method.addJavaDocLine(" */");
        }
    }
    @Override
    public void addSetterComment(Method method, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
        if (introspectedColumn.getRemarks() != null && !introspectedColumn.getRemarks().equals("")) {
            method.addJavaDocLine("/**");
            method.addJavaDocLine(" * "+introspectedColumn.getRemarks());
            method.addJavaDocLine(" * @param  "+introspectedColumn.getActualColumnName()+"  "+introspectedColumn.getRemarks());
            this.addJavadocTag(method, false);
            method.addJavaDocLine(" */");
        }
    }

    @Override
    public void addFieldComment(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
        if (introspectedColumn.getRemarks() != null && !introspectedColumn.getRemarks().equals("")) {
            field.addJavaDocLine("/**");
            field.addJavaDocLine(" * " + introspectedColumn.getRemarks());
            addJavadocTag(field, false);
            field.addJavaDocLine(" */");
        }
    }
}
